﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;
using CakeAnimation;

namespace CharacterAnimationEditor
{

    public class Context
    {
        public AnimationContext AnimationContext;

        public GraphicsDevice GD;
        public SpriteBatch SpriteBatch;
        public ContentManager Content;
        public float DeltaTime;
        public SpriteFont Font;
        public SpriteFont FontBig;

        public Animation Animation;
        public KeyFrame CurrentKeyFrame;
        public Bone HoveredBone;
        public Bone SelectedBone;

        public KeyboardState PrevKeyState;
        public MouseState PrevMouseState;
        public KeyboardState CurrKeyState;
        public MouseState CurrMouseState;
        public Vector2 MousePos;
        public Vector2 PrevMousePos;

        public HelpDisplayInterface HelpDisplay;

        public float Zoom;
        public Vector2 CameraPos;

        public int MouseScroll = 0;

        public Vector2 WindowOffset = Vector2.Zero;
        public Vector2 GetMouseMovement()
        {
            return MousePos - PrevMousePos;
        }

        public void UpdateInputState()
        {
            PrevMouseState = CurrMouseState;
            PrevKeyState = CurrKeyState;
            CurrMouseState = Mouse.GetState();
            CurrKeyState = Keyboard.GetState();

            PrevMousePos = MousePos;
            MousePos = new Vector2(CurrMouseState.X, CurrMouseState.Y);
        }

        public void SetCurrentKeyFrame(KeyFrame kf)
        {
            CurrentKeyFrame = kf;
            SelectedBone = null;
            HoveredBone = null;
        }

        public float GetWindowScale()
        {
            return GD.Viewport.Height / 600.0f;
        }
    }

}
